<?php
namespace Home\Controller;
use Home\Controller\BaseController;
class IndexController extends BaseController {
	public function _initialize(){
	}
    public function index(){
	 //获取分类信息
	  $sql="select * from classfies";
	  $resc=M()->query($sql);
	  for($i=0;$i<count($resc);$i++)
	  {
		  $sql="select * from goods where cid=".$resc[$i]['id']." order by id desc limit 0,5";
		  $resg[$i]['det']=M()->query($sql);
		  $resg[$i]['cname']=$resc[$i]['name'];
		  $resg[$i]['cid']=$resc[$i]['id'];
	  }
	  
	  $sql="select * from display";
	  $rdisplay=M()->query($sql);
	  
	  $sql="select * from goods order by sum desc limit 0,5";
	  $phb=M()->query($sql);
	  
	  $this->assign("phblist",$phb);//销量排行榜
	  $this->assign("display",$rdisplay);//轮播图
	  $this->assign("clist",$resc);//分类
	  $this->assign("list",$resg);//所有
	   $this->display();
    }	
	public function register(){
		$data=I('post.');
		parent::add("users","pic","0","注册");//上传图片，返回值为”注册成功或失败“
		session('user',$data);
		//var_dump($data);exit;
	}	 
}